// components/musics/musics.js
const {get_musicUrl} = require("../../utils/ajax")
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    musicList:{
      type:Object
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    
  },

  created(){
    this.bgManager =  wx.getBackgroundAudioManager()
  },
  /**
   * 组件的方法列表
   */
  methods: {
    // 播放音乐
    playMusic:function(e){
      let item = e.currentTarget.dataset.item
      get_musicUrl({format:"mp3",rid:item.rid,response:"url", type:"convert_url3",br:"128kmp3",from:"web"}).then(res=>{
        this.bgManager.epname = item.album
        this.bgManager.singer = item.artist
        this.bgManager.coverImgUrl = item.pic120
        this.bgManager.title = item.name
        this.bgManager.duration = item.songTimeMinutes
        this.bgManager.src = res.url
      })
    },
  }
})
